package Strategy;

public class TestStrategy {
    public static void main(String[] args){
        Context ctx = new Context();
        ctx.doBehavior();
        ctx.setBehavior(new ConcreteBehavior1());
        ctx.doBehavior();
        ctx.setBehavior(new ConcreteBehavior2());
        ctx.doBehavior();
    }
}

class Context{
    public Context(){
        behavior = new DefaultBehavior();
    }

    public void setBehavior(AbstractBehavior behavior) {
        this.behavior = behavior;
    }

    AbstractBehavior behavior;

    public void doBehavior(){
        behavior.doBehavior();
    }
}

interface AbstractBehavior{
    void doBehavior();
}

class DefaultBehavior implements AbstractBehavior{
    @Override
    public void doBehavior() {
        doDefaultBehavior();
    }

    public void doDefaultBehavior(){
        System.out.println("do Default Behavior");
    }
}

class ConcreteBehavior1 implements AbstractBehavior{
    @Override
    public void doBehavior() {
        doConcreteBehavior();
    }

    private void doConcreteBehavior(){
        System.out.println("do Concrete Behavior1");
    }
}

class ConcreteBehavior2 implements AbstractBehavior{
    @Override
    public void doBehavior() {
        doConcreteBehavior();
    }

    private void doConcreteBehavior(){
        System.out.println("do Concrete Behavior2");
    }
}